import request from '../utils/request'; // 基于axios封装的请求工具

// 企业注册（更新为新的API格式）
export interface RegisterEnterpriseParams {
  username: string;
  email: string;
  password: string;
  role: 'enterprise';
  phone: string;
}

export interface RegisterResponse {
  user_id: number;
  username: string;
  email: string;
  role: string;
}

interface BaseResponse<T = any> {
  code: number;
  message: string;
  data: T;
  trace_id?: string;
}

export const registerEnterprise = (data: RegisterEnterpriseParams): Promise<BaseResponse<RegisterResponse>> => {
  return request({
    url: '/auth/register',
    method: 'post',
    data
  });
};

// 保留其他企业相关API...

// 定义用户登录请求参数类型
export interface LoginParams {
  username: string;
  password: string;
}

// 定义用户信息类型
export interface UserInfo {
  id: number;
  username: string;
  email: string;
  role: 'student' | 'enterprise' | 'admin';
  status: 'active' | 'inactive' | 'suspended';
  nickname?: string;
  avatar?: string;
  phone?: string;
  bio?: string;
  created_at: string;
  updated_at: string;
}

// 定义登录响应数据类型
export interface LoginResponse {
  token: string;
  refresh_token: string;
  user: UserInfo;
}

interface BaseResponse<T = any> {
  code: number;
  message: string;
  data: T;
  trace_id?: string;
}

// 企业登录（更新为新的API格式）
export const loginEnterprise = (data: LoginParams): Promise<BaseResponse<LoginResponse>> => {
  return request({
    url: '/auth/login',
    method: 'post',
    data
  });
};

// 保留其他企业相关API...

interface BaseResponse<T = any> {
  code: number;
  message: string;
  data: T;
  trace_id?: string;
}

// 获取企业信息（更新为新的API格式）
export const getEnterpriseInfo = (): Promise<BaseResponse<UserInfo>> => {
  return request({
    url: '/user/me',  // 更新为新的API端点
    method: 'get'
  });
};

// 保留其他企业相关API...
